package com.example.makerspace.controller.customer;

import cn.hutool.core.lang.Dict;
import com.example.makerspace.domain.ImsingleDO;
import com.example.makerspace.dto.Result;
import com.example.makerspace.dto.robotDTO.ImsingleDTO;
import com.example.makerspace.service.CustomerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
@RestController
@RequestMapping(value = "/api/imsingle")
@Api(tags = "人工服务模块")
public class CustomerController {
        @Resource
        private CustomerService customerService;

        /**
         * 查询所有消息
         */

        @ApiOperation(value="查询所有消息接口",notes ="查询所有消息接口说明")
        @GetMapping
        public Result findByFromUsername(@RequestParam String fromUser, @RequestParam String toUser) {
            List<ImsingleDO> all = customerService.findByUsername(fromUser, toUser);
            return Result.success(all);
        }

        /**
         * 查询未读消息数量
         * @return 未读消息数量
         */
        @ApiOperation(value="查询未读消息接口",notes ="查询未读消息接口说明")
        @GetMapping("/unReadNums")
        public Result findUnReadNums(@RequestParam String toUsername) {
            Dict dict = customerService.findUnReadNums(toUsername);
            return Result.success(dict);
        }

     /**
     * 插入消息接口
     * @param imsingleDTO
     * @return
     */
       @ApiOperation(value="插入消息接口",notes ="插入消息接口说明")
       @PostMapping("/insertMessage")
       public Result insertMessage(@RequestBody ImsingleDTO imsingleDTO) {
             return  customerService.insertMessage(imsingleDTO);

    }

    /**
     * 查询用户列表接口
     * @return
     */
    @ApiOperation(value="查询用户列表接口",notes ="查询用户列表接口说明")
    @GetMapping("/selectUserList")
    public Result selectUserList() {
        return  customerService.selectUserList();
    }

    /**
     * 结束通话接口
     * @return
     */
    @ApiOperation(value="结束通话接口",notes ="结束通话接口说明")
    @GetMapping("/stopSession")
    public Result stopSession(@RequestParam String fromUser) {
        return  customerService.stopSession(fromUser);
    }
}
